package com.ssy.lingxi.order.repository;

import com.ssy.lingxi.order.entity.OrderDO;
import com.ssy.lingxi.order.entity.OrderProductDO;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 订单商品Jpa仓库
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-15
 */
@Repository
public interface OrderProductRepository extends JpaRepository<OrderProductDO, Long>, JpaSpecificationExecutor<OrderProductDO>, QuerydslPredicateExecutor<OrderProductDO> {
    List<OrderProductDO> findByOrder(OrderDO order);

    List<OrderProductDO> findByOrder(OrderDO order, Sort sort);

    List<OrderProductDO> findByOrderIn(List<OrderDO> orders);

    @Transactional
    void deleteByOrder(OrderDO order);

    List<OrderProductDO> findByIdIn(List<Long> orderProductIds);
}
